#!/usr/bin/env bash
tempfile=`date '+%Y%m%d%H%M%S'`.txt
echo $tempfile

for i in `find /usr/tomcat/apache-tomcat-7.0.64/logs/ -name localhost_access_log*`
do
 echo $i
 if [ -s $i ]
 then
    cat $i >> $tempfile
    rm -f $i
 fi
done

if [ -s $tempfile ]
then
    hdfs dfs -put $tempfile /input
    rm -f $tmpfile

    hdfs dfs -rmr /output
    hadoop jar count-jar-with-dependencies.jar com.ecmaster.search.count.Counter /input /output

    hdfs dfs -rmr /input/*
fi